package com.schoolCommunity.mapper;

import com.schoolCommunity.entity.ConfessionWall;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author YTH
 * @since 2020-09-09
 */
public interface ConfessionWallMapper extends BaseMapper<ConfessionWall> {

    //获取现在有的最大期数
    @Select("select distinct  MAX(`periods`) from confession_wall")
    public Integer getMaxPeriods();

    //点赞
    @Update("update `confession_wall` set loves=loves+1 where id = #{confessionWallId}")
    public Integer AddLoves(long confessionWallId);

    //写入表白墙并返回id
    @Insert("insert into confession_wall(title,text,member_id,member_nickname,time) values(#{title},#{text},#{memberId},#{memberNickname},#{time})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    int insertConfessionWall(ConfessionWall confessionWall);


}
